package com.bjut.vehicleshow.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bjut.vehicleshow.dao.StationInfoMapper;
import com.bjut.vehicleshow.pojo.CarTrainingDO;
import com.bjut.vehicleshow.pojo.StationInfoDO;
import com.bjut.vehicleshow.util.GPSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * All rights Reserved, Designed By www.sac.com
 *
 * @author 王文贵
 * @version V1.0.0
 * @projectName sac-web-rpc-server
 * @title StuServiceImpl
 * @package com.sac.scada.rpc.web.stu.service
 * @description
 * @date 2020/2/12
 * @copyright www.sac.com
 * 注意 本内容仅限于国电南自,禁止外泄以及用于其他的商业
 */
@Service
public class StationInfoServiceImpl implements StationInfoService {

    @Autowired
    private StationInfoMapper stationInfoMapper;

    @Override
    public List<StationInfoDO> getStation(Integer flag) {
        List<StationInfoDO> stationInfoDOS = new ArrayList<>();
        if (flag != null) {
            stationInfoDOS = stationInfoMapper.selectList(new QueryWrapper<StationInfoDO>().eq("Flag", flag));
        } else {
            stationInfoDOS = stationInfoMapper.selectList(null);
        }
        for (StationInfoDO stationInfoDO : stationInfoDOS) {
            double[] locations = GPSUtil.gps84_To_Gcj02(stationInfoDO.getLatitude(), stationInfoDO.getLongitude());
            stationInfoDO.setLatitude(locations[0]);
            stationInfoDO.setLongitude(locations[1]);
        }
        return stationInfoDOS;
    }
}
